package com.muyu.cloud.commodity.controller;

import com.muyu.cloud.commodity.domain.req.ProductStatsReq;
import com.muyu.cloud.commodity.domain.resp.ProductStatsResp;
import com.muyu.cloud.commodity.service.ProductStatsService;
import com.muyu.common.core.domain.Result;
import com.muyu.common.security.annotation.RequiresPermissions;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 商品统计控制器
 * @author muyu
 * @date 2025/01/20
 */
@RestController
@RequestMapping("/product/stats")
@Tag(name = "ProductStatsController", description = "商品统计管理")
public class ProductStatsController {

    @Autowired
    private ProductStatsService productStatsService;

    /**
     * 获取商品统计概览
     */
    @Operation(summary = "获取商品统计概览")
    @RequiresPermissions("product:stats:overview")
    @PostMapping("/overview")
    public Result<ProductStatsResp> getStatsOverview(@RequestBody ProductStatsReq req) {
        ProductStatsResp resp = productStatsService.getStatsOverview(req);
        return Result.success(resp);
    }

    /**
     * 获取商品趋势数据
     */
    @Operation(summary = "获取商品趋势数据")
    @RequiresPermissions("product:stats:trend")
    @PostMapping("/trend")
    public Result<ProductStatsResp> getTrendData(@RequestBody ProductStatsReq req) {
        ProductStatsResp resp = productStatsService.getTrendData(req);
        return Result.success(resp);
    }

    /**
     * 获取商品排行数据
     */
    @Operation(summary = "获取商品排行数据")
    @RequiresPermissions("product:stats:ranking")
    @PostMapping("/ranking")
    public Result<ProductStatsResp> getProductRanking(@RequestBody ProductStatsReq req) {
        ProductStatsResp resp = productStatsService.getProductRanking(req);
        return Result.success(resp);
    }
}









